

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;

public class StreamUtil {

	public static String convertStreamToString(InputStream is) throws IOException {
		if (is != null) {
			Writer writer = new StringWriter();

			char[] buffer = new char[4096];
			int i = 0;

			Reader reader = new BufferedReader(new InputStreamReader(is));
			i = reader.read(buffer);
			if (i < 0)
				return "";
			writer.write(buffer, 0, i);

			return writer.toString();
		} else {
			return "";
		}
	}
}
